﻿@model IEnumerable<CloudFranceTriple.WebRole.Models.PollItem>
@{
    ViewBag.Title = CloudFranceTriple.WebRole.Properties.Resources.PollIndexTitle;
    Layout = "~/Views/Shared/_Layout.cshtml";
}
<div class="content-padding">
    <h1>
        @CloudFranceTriple.WebRole.Properties.Resources.PollIndexTitle
    </h1>
    <section>
        <p>
            @if (ViewBag.IsAuthor)
            {
                @Html.ActionLink(@CloudFranceTriple.WebRole.Properties.Resources.PollCreateBouton, "Create", "Poll", new { area = "Forum" }, null)
            }
        </p>
        <table>
            <tr>
                <th>
                    @CloudFranceTriple.WebRole.Properties.Resources.PollLabel
                </th>
                <th>
                    @CloudFranceTriple.WebRole.Properties.Resources.PollDescription
                </th>
                <th>
                    @CloudFranceTriple.WebRole.Properties.Resources.PollCreationDate
                </th>
                <th>
                    @CloudFranceTriple.WebRole.Properties.Resources.PollDurationInDays
                </th>
                <th>
                    @CloudFranceTriple.WebRole.Properties.Resources.PollIsPublicPollResult
                </th>
                <th>
                    @CloudFranceTriple.WebRole.Properties.Resources.PollIsMemberOnlyPoll
                </th>
                <th>
                    @CloudFranceTriple.WebRole.Properties.Resources.TopicLabel
                </th>
                <th></th>
            </tr>

            @foreach (var item in Model)
            {
                <tr>
                    <td>
                        @Html.DisplayFor(modelItem => item.LabelPoll)
                    </td>
                    <td>
                        @Html.DisplayTextFor(modelItem => item.DescriptionPoll)
                    </td>
                    <td>
                        @Html.DisplayFor(modelItem => item.CreationDatePoll, "TemplateUserDate")
                    </td>
                    <td>
                        @Html.DisplayFor(modelItem => item.DurationInDays)
                    </td>
                    <td>
                        @Html.DisplayFor(modelItem => item.IsPublicPollResult)
                    </td>
                    <td>
                        @Html.DisplayFor(modelItem => item.IsMemberOnlyPoll)
                    </td>
                    <td>
                        @if (item.LabelForumTopic != String.Empty)
                        {
                            @Html.ActionLink(Server.HtmlDecode(item.LabelForumTopic), "Index", "Post", new { id = item.ForumTopic_Id, area = "Forum" }, null)
                        }
                    </td>
                    <td>
                        @if (item.ShowResults)
                        {
                            @Html.ActionLink(CloudFranceTriple.WebRole.Properties.Resources.ButtonResults, "Results", "Poll", new { id = item.Id, area = "Forum" }, null)
                        }
                        @if (ViewBag.IsAuthor && !item.HasPolled && !item.ShowResults)
                        {
                            @Html.ActionLink(CloudFranceTriple.WebRole.Properties.Resources.ButtonEdit, "Edit", "Poll", new { id = item.Id, area = "Forum" }, null)
                            @Html.ActionLink(CloudFranceTriple.WebRole.Properties.Resources.ButtonDelete, "Delete", "Poll", new { id = item.Id, area = "Forum" }, null)
                        }
                    </td>
                </tr>
            }
        </table>
        @if (((ViewBag.Topic_Id as int?) ?? 0) > 0)
        {
            @Html.Partial("_PollBackToPostListByTopic")
        }
    </section>
</div>
